# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: $

DESCRIPTION="Proxy cache for Gentoo packages"
HOMEPAGE="http://gertjan.freezope.org/"
SRC_URI="http://gertjan.freezope.org/replicator/${PN}_${PV}.tar.gz"

LICENSE="GPL-2.0"
SLOT="0"
KEYWORDS="x86 amd64 alpha ppc"
IUSE=""

DEPEND=">=dev-lang/python-2.3"

src_compile() {
	einfo "No compilation neccessary"
}

src_install(){
	# Daemon and repcacheman into /usr/bin
	exeinto /usr/bin
	doexe http-replicator
	newexe ${FILESDIR}/http-replicator-3.0-callrepcacheman-0.1 repcacheman
	if has_version '>=sys-apps/portage-2.0.51'; then
		newexe ${FILESDIR}/http-replicator-3.0-repcacheman-0.33 repcacheman.py
	else
		newexe ${FILESDIR}/http-replicator-3.0/repcacheman-0.21 repcacheman.py
	fi
	


	# Config file into /etc/conf.d
	insinto /etc/conf.d
	newins ${FILESDIR}/http-replicator-3.0.conf http-replicator

	# Doc's
	dodoc README
	dodoc debian/changelog
	dodoc debian/copyright

	# init.d scripts
	exeinto /etc/init.d 
	newexe ${FILESDIR}/http-replicator-3.0.init  http-replicator
	
	# Man Page - Not Gentooified yet
	doman http-replicator.1
	
	# If Logrotate
	if test -d /etc/logrotate.d ; then
		insinto /etc/logrotate.d
		newins debian/logrotate http-replicator
	else
		dodoc debian/logrotate
	fi
}


pkg_postinst() {
	einfo
	einfo "If you wish to change defaults"
	einfo "edit /etc/conf.d/http-replicator"
	einfo
	einfo "Execute /usr/bin/repcacheman "
	einfo "to auto create the cache directory"
	einfo "and prime the cache."
	einfo
	einfo "Upgrades: Don't forget to restart Http-Replicator!"
	einfo
}


